<?php
namespace Products;


class CreditCard extends Cards
{
	protected $annualFee;
	protected $type;
	
	protected $name;
	protected $amount;
	
	public function __construct($name, $type)
	{
		parent::__construct($name, $type);
		$annualFee = 50;		
	}
	
	public function setAnnualFee($annualFee)
	{
		if(is_numeric($annualFee) && $annualFee > 0 && !($annualFee == null))
		{
			$this->annualFee = $annualFee;
		}else
		{
			throw new BaseException("Invalid entered annual fee!", BaseException::CODE_4001);
		}
	}
	
	public function setType($type)
	{
		if (is_string($type) && ($type == "Maestro" || $type == "Visa") && !($type == null))
		{
			$this->type = $type;
		}else
		{
			throw new BaseException("Invalid entry for type of the card!", BaseException::CODE_4002);
		}
	}
	
	public function setName($name)
	{
		if(is_string($name) && strlen($name) > 3 && !(is_numeric($name)) && !($name == null))
		{
			$this->name = $name;
		}else
		{
			throw new BaseException("Invalid entered owner's name!", BaseException::CODE_4003);
		}
	}
	
	public function setAmount($amount)
	{
		if(is_numeric($amount) && $amount > 0 && !($amount == null))
		{
			$this->amount = $amount;
		}else
		{
			throw new BaseException("The entered amount is not acceptable", BaseException::CODE_4004);
		}
	}
	
	public function showInfo()
	{
		parent::showInfo();
	}
	
}
